package com.uye.tattstemp.command;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.uye.framework.command.BaseStatefulJSONCommand;
import com.uye.framework.dto.BaseJSONRequest;
import com.uye.framework.exception.InternalServerException;
import com.uye.framework.model.IGenericDAO;
import com.uye.tattstemp.dto.GetAllProductivityTypesResponse;
import com.uye.tattstemp.model.ProductivityType;

@Transactional
public class GetAllProductivityTypesCommand extends
		BaseStatefulJSONCommand<BaseJSONRequest> {

	@Autowired
	private IGenericDAO<ProductivityType, Long> productivityTypeDAO;

	@Override
	public void undo() {
		// no need to undo anything
	}

	@Override
	public void executeCommand() throws InternalServerException {
		GetAllProductivityTypesResponse response = new GetAllProductivityTypesResponse(
				getModel().getServiceName());
		response.setProductivityTypes(productivityTypeDAO.getAll());
		sendResponse(response);
	}

}
